<template>
  <div class="label-progress">
    <div class="label-line">
      <div class="label">
        {{label}}
      </div>
      <div class="current">
        {{currentCount}}
      </div>
    </div>

    <div class="progress-line">
      <div class="current-progress" :style="{width: progressPercentage}"/>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    label: {
      type: String,
      default: ''
    },
    currentCount: {
      type: Number,
      default: 0,
    },
    total: {
      type: Number,
      default: 0,
    },
  },

  computed: {
    progressPercentage() {
      if (!this.total) {
        return '0%'
      }

      const _currentCount = this.currentCount > this.total ? this.total : this.currentCount
      const percentageValue = (_currentCount / this.total * 100).toFixed(2)
      return percentageValue + '%'
    }
  }
}
</script>

<style scoped lang="scss">
.label-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}

.progress-line {
  height: 20px;
  background: rgba(236, 239, 255, 1);

  .current-progress {
    background: rgba(97, 120, 255, 1);
    height: 100%;
  }
}
</style>
